import pymongo

my_client = pymongo.MongoClient("mongodb://localhost:27017/")
my_db = my_client["darker"]

my_col = my_db["sites"]

my_dict = {"name": "Darker", "age": "18", "gender": "male"}

# x = my_col.insert_one(my_dict)
# print(x)
# print(x.inserted_id)


my_list = [
    {"name": "AAA", "age": "18", "gender": "male"},
    {"name": "BBB", "age": "18", "gender": "female"},
    {"name": "CCC", "age": "18", "gender": "male"},
    {"name": "DDD", "age": "18", "gender": "female"},
]

# second = my_col.insert_many(my_list)
#
# # 输出插入的所有文档对应的 _id 值
# print(second.inserted_ids)


my_list_2 = [
    {"_id": 1, "name": "AAA", "age": "18", "gender": "male"},
    {"_id": 2, "name": "BBB", "age": "18", "gender": "female"},
    {"_id": 3, "name": "CCC", "age": "18", "gender": "male"},
    {"_id": 4, "name": "DDD", "age": "18", "gender": "female"},
]

third = my_col.insert_many(my_list_2)

# 输出插入的所有文档对应的 _id 值
print(third.inserted_ids)
